<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--    <link href="style/demo.css" rel="stylesheet" type="text/css"/>-->
<!--    <script src="scripts/jquery-1.9.1.js" type="text/javascript"></script>-->
<!--    <script src="scripts/demo.js" type="text/javascript"></script>-->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Qddr5eeG0LCOygAnBTWglfyvXnDbOWD5"></script>
    <script type="text/javascript"
            src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css"/>
</head>
<body>
<div class="demo_main">
    <fieldset class="demo_content">
        <div style="min-height: 500px; width: 100%;" id="map">
        </div>
        <script type="text/javascript">
            var markerArr;
            axios.get("/address/findAll").then(response => {
                console.log(response.data.data);
                if (response.data.flag) {
                    markerArr = response.data.data;
                    map_load();
                } else {
                    this.$message.error(response.data.message);
                }
            });

            function map_init() {
                var map = new BMap.Map("map"); // 创建Map实例
                //var point = new BMap.Point(120.188876, 30.228258); //地图中心点
                map.centerAndZoom("杭州", 12); // 初始化地图,设置中心点坐标和地图级别。
                map.enableScrollWheelZoom(true); //启用滚轮放大缩小
                //地图、卫星、混合模式切换
                map.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP]}));
                //向地图中添加缩放控件
                var ctrlNav = new window.BMap.NavigationControl({
                    anchor: BMAP_ANCHOR_TOP_LEFT,
                    type: BMAP_NAVIGATION_CONTROL_LARGE
                });
                map.addControl(ctrlNav);
                //向地图中添加缩略图控件
                var ctrlOve = new window.BMap.OverviewMapControl({
                    anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
                    isOpen: 1
                });
                map.addControl(ctrlOve);
                //向地图中添加比例尺控件
                var ctrlSca = new window.BMap.ScaleControl({
                    anchor: BMAP_ANCHOR_BOTTOM_LEFT
                });
                map.addControl(ctrlSca);

                var point = new Array(); //存放标注点经纬信息的数组
                var marker = new Array(); //存放标注点对象的数组
                var info = new Array(); //存放提示信息窗口对象的数组
                var searchInfoWindow = new Array();//存放检索信息窗口对象的数组
                for (var i = 0; i < markerArr.length; i++) {
                    var p0 = markerArr[i].ad_jd; //
                    var p1 = markerArr[i].ad_wd; //按照原数组的point格式将地图点坐标的经纬度分别提出来
                    point[i] = new window.BMap.Point(p0, p1); //循环生成新的地图点
                    marker[i] = new window.BMap.Marker(point[i]); //按照地图点坐标生成标记
                    map.addOverlay(marker[i]);
                    // marker[i].setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
                    //显示marker的title，marker多的话可以注释掉
                    var label = new window.BMap.Label(markerArr[i].ad_name, {offset: new window.BMap.Size(20, -10)});
                    marker[i].setLabel(label);
                    // 创建信息窗口对象
                    info[i] = "<p style='font-size:12px;lineheight:1.8em'>" + "</br>地址：" + markerArr[i].addressDetail + "</br> 电话：" + markerArr[i].telephone + "</br></p>";
                    //创建百度样式检索信息窗口对象
                    searchInfoWindow[i] = new BMapLib.SearchInfoWindow(map, info[i], {
                        title: markerArr[i].title,      //标题
                        width: 290,             //宽度
                        height: 55,              //高度
                        panel: "panel",         //检索结果面板
                        enableAutoPan: true,     //自动平移
                        searchTypes: [
                            BMAPLIB_TAB_SEARCH,   //周边检索
                            BMAPLIB_TAB_TO_HERE,  //到这里去
                            BMAPLIB_TAB_FROM_HERE //从这里出发
                        ]
                    });
                    //添加点击事件
                    marker[i].addEventListener("click",
                        (function (k) {
                            // js 闭包
                            return function () {
                                //将被点击marker置为中心
                                //map.centerAndZoom(point[k], 18);
                                //在marker上打开检索信息窗口
                                searchInfoWindow[k].open(marker[k]);
                            }
                        })(i)
                    );
                }
            }

            //异步调用百度js
            function map_load() {
                var load = document.createElement("script");
                load.src = "http://api.map.baidu.com/api?v=2.0&callback=map_init";
                document.body.appendChild(load);
            }
        </script>
    </fieldset>
</div>
</body>
</html>




<!--
<!DOCTYPE html>
<html>
<head>
    &lt;!&ndash; 页面meta &ndash;&gt;
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    &lt;!&ndash; 引入样式 &ndash;&gt;
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
        #l-map{height:300px;width:100%;}
        #r-result{width:100%; font-size:14px;line-height:20px;}
    </style>
    <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak="></script>

    &lt;!&ndash; 引入样式 &ndash;&gt;
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">

    &lt;!&ndash; 引入组件库 &ndash;&gt;
&lt;!&ndash;    <script src="../plugins/elementui/index.js"></script>&ndash;&gt;
    <script src="../js/axios-0.18.0.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <div id="allmaps" style="height: 520px;width: 1380px;" ></div>
    <div id="r-result">
        <input type="button" value="批量反地址解析+健康圈" @click="bdGEO(0)" />
        <div id="result"></div>
    </div>
</div>
<script type="text/javascript">

</script>
&lt;!&ndash;<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmaps");    // 创建Map实例
    map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);  // 初始化地图,设置中心点坐标和地图级别
    //添加地图类型控件
    map.addControl(new BMap.MapTypeControl({
        mapTypes:[
            BMAP_NORMAL_MAP,
            BMAP_HYBRID_MAP
        ]}));
    map.setCurrentCity("北京");          // 设置地图显示的城市 此项是必须设置的
    map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
</script>&ndash;&gt;

<script>

//    function initMap(points) {
//        // 百度地图API功能
//        var map = new BMap.Map("allmaps");
//        map.centerAndZoom(new BMap.Point(116.328749,40.026922), 13);
//        map.enableScrollWheelZoom(true);
//        var index = 0;
//        var myGeo = new BMap.Geocoder();
//
//        // 根据传入的points ， 构造标记数据
//
//        // var adds = [
//        //     new BMap.Point(116.307852,40.057031),
//        //     new BMap.Point(116.313082,40.047674),
//        //     new BMap.Point(116.328749,40.026922),
//        //     new BMap.Point(116.347571,39.988698),
//        //     new BMap.Point(116.316163,39.997753),
//        //     new BMap.Point(116.345867,39.998333),
//        //     new BMap.Point(116.403472,39.999411),
//        //     new BMap.Point(116.307901,40.05901)
//        // ];
//
//        alert(points.ad_name);
//        for(var i = 0; i<points.length; i++){
//            var marker = new BMap.Marker(new BMap.Point(points.ad_jd,points.ad_wd));
//            map.addOverlay(marker);
//            marker.setLabel(new BMap.Label(points.ad_name,{offset:new BMap.Size(20,-10)}));
//        }
//    }
//
//    function bdGEO(){
//        var pt = adds[index];
//        geocodeSearch(pt);
//        index++;
//    }
//    function geocodeSearch(pt){
//        if(index < adds.length-1){
//            setTimeout(window.bdGEO,400);
//        }
//        myGeo.getLocation(pt, function(rs){
//            var addComp = rs.addressComponents;
//            document.getElementById("result").innerHTML += index + ". " +adds[index-1].lng + "," + adds[index-1].lat + "："  + "商圈(" + rs.business + ")  结构化数据(" + addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber + ")<br/><br/>";
//        });
//    }
//
//
    var markerArr;
    axios.get("/address/findAll").then(response => {
        if (response.data.flag) {
            markerArr = response.data.data;
            map_load();
        } else {
            this.$message.error(response.data.message);
        }
    })
    function map_init() {
        var map = new BMap.Map("map"); // 创建Map实例
        //var point = new BMap.Point(120.188876, 30.228258); //地图中心点
        map.centerAndZoom("杭州", 12); // 初始化地图,设置中心点坐标和地图级别。
        map.enableScrollWheelZoom(true); //启用滚轮放大缩小
        //地图、卫星、混合模式切换
        map.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP]}));
        //向地图中添加缩放控件
        var ctrlNav = new window.BMap.NavigationControl({
            anchor: BMAP_ANCHOR_TOP_LEFT,
            type: BMAP_NAVIGATION_CONTROL_LARGE
        });
        map.addControl(ctrlNav);
        //向地图中添加缩略图控件
        var ctrlOve = new window.BMap.OverviewMapControl({
            anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
            isOpen: 1
        });
        map.addControl(ctrlOve);
        //向地图中添加比例尺控件
        var ctrlSca = new window.BMap.ScaleControl({
            anchor: BMAP_ANCHOR_BOTTOM_LEFT
        });
        map.addControl(ctrlSca);

        var point = new Array(); //存放标注点经纬信息的数组
        var marker = new Array(); //存放标注点对象的数组
        var info = new Array(); //存放提示信息窗口对象的数组
        var searchInfoWindow = new Array();//存放检索信息窗口对象的数组
        for (var i = 0; i < markerArr.length; i++) {
            var p0 = markerArr[i].ad_jd; //
            var p1 = markerArr[i].ad_wd; //按照原数组的point格式将地图点坐标的经纬度分别提出来
            point[i] = new window.BMap.Point(p0, p1); //循环生成新的地图点
            marker[i] = new window.BMap.Marker(point[i]); //按照地图点坐标生成标记
            map.addOverlay(marker[i]);
            marker[i].setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
            //显示marker的title，marker多的话可以注释掉
            var label = new window.BMap.Label(markerArr[i].ad_name, {offset: new window.BMap.Size(20, -10)});
            marker[i].setLabel(label);
            // 创建信息窗口对象
            info[i] = "<p style='font-size:12px;lineheight:1.8em'>" + "</br>地址：" + markerArr[i].ad_particulars + "</br> 电话：" + markerArr[i].ad_phone + "</br></p>";
            //创建百度样式检索信息窗口对象
            searchInfoWindow[i] = new BMapLib.SearchInfoWindow(map, info[i], {
                title: markerArr[i].title,      //标题
                width: 290,             //宽度
                height: 55,              //高度
                panel: "panel",         //检索结果面板
                enableAutoPan: true,     //自动平移
                searchTypes: [
                    BMAPLIB_TAB_SEARCH,   //周边检索
                    BMAPLIB_TAB_TO_HERE,  //到这里去
                    BMAPLIB_TAB_FROM_HERE //从这里出发
                ]
            });
            //添加点击事件
            marker[i].addEventListener("click",
                (function (k) {
                    // js 闭包
                    return function () {
                        //将被点击marker置为中心
                        //map.centerAndZoom(point[k], 18);
                        //在marker上打开检索信息窗口
                        searchInfoWindow[k].open(marker[k]);
                    }
                })(i)
            );
        }
    }

    //异步调用百度js
    function map_load() {
        var load = document.createElement("script");
        load.src = "http://api.map.baidu.com/api?v=2.0&callback=map_init";
        document.body.appendChild(load);
    }
</script>
</body>

</html>
-->
